package cn.zysheep.order;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.client.RestTemplate;


/**
 * @EnableHystrix 是 {@link EnableCircuitBreaker}的组合注解
 * @SpringCloudApplication是下面三个注解的组合注解
 *   @see SpringBootApplication
 *   @see EnableDiscoveryClient
 *   @see EnableCircuitBreaker
 */
//@SpringCloudApplication
//@EnableHystrix //开启熔断器
@EnableDiscoveryClient
@SpringBootApplication
@EnableFeignClients(basePackages = "cn.zysheep.feign.clients")
@MapperScan("cn.zysheep.order.mapper")
@ComponentScan(basePackages = {"cn.zysheep"})
//@Import({Swagger2Config.class})
public class OrderApplication {

    public static void main(String[] args) {
        SpringApplication.run(OrderApplication.class, args);
    }

    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    /**
     * 自定义负载均衡策略
     * 1. 注册Bean方式设置
     * 2. yml配置文件中设置
     * @return
     */
//    @Bean
//    public IRule randomRule() {
//        return new RandomRule();
//    }
}